package com.tucue.controller;
/*2015
* By Ada
* */

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.tucue.adapter.GenericAdapter;
import com.tucue.dao.*;
import com.tucue.model.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.tucue.controller.*;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/query")
public class QueryController extends BaseController
{
    /*园区管理  开始*/

    /*园区资讯*/
    @RequestMapping(value="/parkQueryNews", method = RequestMethod.GET)
    public ModelAndView  parkQueryNews()
    {

        try
        {
            this.getSqlSession();
            NewsMapper mapper=sqlSession.getMapper(NewsMapper.class);
            List<News> newsList = mapper.selectAll();
            view.setViewName("parkQueryNews");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(newsList);
            //System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*园区资讯 详情页面,newsid为页面传递过来的参数，注意写法*/
    @RequestMapping(value = "/parkDetailsNews/{newsid}",method = RequestMethod.GET)
    public ModelAndView parkDetailsNews(@PathVariable Integer newsid)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("parkDetailsNews");
            NewsMapper mapper=sqlSession.getMapper(NewsMapper.class);
            News news=mapper.selectByPrimaryKey(newsid);
            view.addObject("news",news);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*园区资讯 编辑页面*/
    @RequestMapping(value = "/parkAddNews/{newsid}",method = RequestMethod.GET)
    public ModelAndView parkAddNews(@PathVariable Integer newsid)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("parkAddNews");
            NewsMapper mapper=sqlSession.getMapper(NewsMapper.class);
            News news=mapper.selectByPrimaryKey(newsid);
            view.addObject("news",news);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*园区活动*/
    @RequestMapping(value="/parkQueryActivity", method = RequestMethod.GET)
    public ModelAndView parkQueryActivity ()
    {
        try
        {
            this.getSqlSession();
            ActivityMapper mapper=sqlSession.getMapper(ActivityMapper.class);
            List<Activity> activityList = mapper.selectAll(1);
            view.setViewName("parkQueryActivity");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(activityList);
            System.out.println(json);
            view.addObject("data", json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }

    }

    /*园区活动 编辑*/
    @RequestMapping(value = "/parkaddActivity/{activityid}",method = RequestMethod.GET)
    public ModelAndView parkaddActivity(@PathVariable Integer activityid)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("parkaddActivity");
            ActivityMapper mapper=sqlSession.getMapper(ActivityMapper.class);
            Activity activities=mapper.selectByPrimaryKey(activityid);
            view.addObject("activities",activities);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*园区活动 详情*/
    @RequestMapping(value = "/parkDetailsActivity/{activityid}",method = RequestMethod.GET)
    public ModelAndView parkDetailsActivity(@PathVariable Integer activityid)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("parkDetailsActivity");
            ActivityMapper mapper = sqlSession.getMapper(ActivityMapper.class);
            Activity activities = mapper.selectByPrimaryKey(activityid);
            view.addObject("activities", activities);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*园区活动申请  查询某一个活动的全部申请*/
    @RequestMapping(value = "/parkActivityApply/{activityid}", method = RequestMethod.GET)
    public ModelAndView parkActivityApply (@PathVariable Integer activityid)
    {
        try
        {
            this.getSqlSession();
            ActivityApplyMapper mapper=sqlSession.getMapper(ActivityApplyMapper.class);
            //List<ActivityApply> activityApplyList = mapper.selectAll(activityid);
            List<Map<String,String>> activityApplyList = mapper.activityApplyInfo(activityid);
            view.setViewName("parkActivityApply");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(activityApplyList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }

    }

    /*园区招商政策管理*/
    @RequestMapping(value="/parkPolicyManage", method = RequestMethod.GET)
    public ModelAndView parkPolicyManage(HttpSession session,ModelMap model) {
        try
        {
            this.getSqlSession();
            view.setViewName("parkPolicyManage");
            MerchantsPolicyMapper merchantsPolicyMapper=sqlSession.getMapper(MerchantsPolicyMapper.class);

            int parkID=getCurrentUser(session).getParkid();

            MerchantsPolicy merchantsPolicy=merchantsPolicyMapper.selectMerchantsPolicyInfo(parkID);

            if(merchantsPolicy!=null){
                view.addObject("merchantsPolicy",merchantsPolicy);
                model.addAttribute("addOrUpdate","update");
            }else{
                model.addAttribute("addOrUpdate","add");
            }
            return view;
        } catch (Exception ex) {
            ex.printStackTrace();
            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*园区招商政策管理 编辑页面*/
    @RequestMapping(value = "/parkAddPolicy/{merchantsPolicyID}",method = RequestMethod.GET)
    public ModelAndView parkDetailsPolicy(@PathVariable Integer merchantsPolicyID)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("parkAddPolicy");
            MerchantsPolicyMapper mapper = sqlSession.getMapper(MerchantsPolicyMapper.class);
            MerchantsPolicy policy = mapper.selectByPrimaryKey(merchantsPolicyID);
            view.addObject("policy", policy);
            String title = "园区招商政策编辑";
            view.addObject("titlename",title);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }


    /*招商申请政策*/
    @RequestMapping(value="/parkQueryApply", method = RequestMethod.GET)
    public ModelAndView  parkQueryApply()
    {

        try
        {
            this.getSqlSession();
            MerchantsOrderMapper mapper=sqlSession.getMapper(MerchantsOrderMapper.class);
            // List<MerchantsOrder> merchantsOrdersList = mapper.selectAll();
            List<Map<String,String>>  merchantsOrdersList=mapper.selectMerchantsOrderDetail(1);

            view.setViewName("parkQueryApply");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(merchantsOrdersList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName("error");
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*招商申请政策  详情以及审核订单*/
    @RequestMapping(value = "/parkOrderDetails/{merchantsOrderID}",method = RequestMethod.GET)
    public ModelAndView parkOrderDetails(@PathVariable Integer merchantsOrderID)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("parkOrderDetails");
            //  view.setViewName("test");
            MerchantsOrderMapper mapper = sqlSession.getMapper(MerchantsOrderMapper.class);
            List<MerchantsOrder>  merchantsOrderlist=mapper.selectByPrimaryKey(merchantsOrderID);
            view.addObject("merchantsOrderlist",merchantsOrderlist);

            //查订单进度
            OrderStatusMapper mapper2 = sqlSession.getMapper(OrderStatusMapper.class);
            List<OrderStatus> orderStatusList=mapper2.selectOrderStatus(merchantsOrderID, 1);
            view.addObject("orderStatusList",orderStatusList);

            //查询招商政策名称
            MerchantsPolicyMapper mapper3 = sqlSession.getMapper(MerchantsPolicyMapper.class);
            MerchantsPolicy mechantsPolicyInfo=mapper3.selectMerchantsPolicyInfo(1);
            view.addObject("mechantsPolicyInfo",mechantsPolicyInfo);

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();
            String json = gson.toJson(orderStatusList);
            System.out.println(json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    @RequestMapping(value = "/parkOrderManage/{merchantsOrderID}",method = RequestMethod.GET)
    public ModelAndView parkOrderManage(@PathVariable Integer merchantsOrderID)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("parkOrderManage");
            //  view.setViewName("test");
            MerchantsOrderMapper mapper = sqlSession.getMapper(MerchantsOrderMapper.class);
            List<MerchantsOrder>  merchantsOrderlist=mapper.selectByPrimaryKey(merchantsOrderID);
            view.addObject("merchantsOrderlist",merchantsOrderlist);

            //查订单进度
            OrderStatusMapper mapper2 = sqlSession.getMapper(OrderStatusMapper.class);
            List<OrderStatus> orderStatusList=mapper2.selectOrderStatus(merchantsOrderID, 1);
            view.addObject("orderStatusList",orderStatusList);

            //查询招商政策名称
            MerchantsPolicyMapper mapper3 = sqlSession.getMapper(MerchantsPolicyMapper.class);
            MerchantsPolicy mechantsPolicyInfo=mapper3.selectMerchantsPolicyInfo(1);
            view.addObject("mechantsPolicyInfo",mechantsPolicyInfo);

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();
            String json = gson.toJson(orderStatusList);
            System.out.println(json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }


    /*园区客服*/
    @RequestMapping(value="/parkServer", method = RequestMethod.GET)
    public ModelAndView parkServer ()
    {
        try
        {
            this.getSqlSession();
            ConsultMapper mapper=sqlSession.getMapper(ConsultMapper.class);
            List<Consult> consultList = mapper.selectAll(1);
            view.setViewName("parkServer");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(consultList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }

    }

    /*园区客服详情*/
    @RequestMapping(value = "/parkreply/{consultid}",method = RequestMethod.GET)
    public ModelAndView parkServer(@PathVariable Integer consultid)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("parkReply");
            ConsultMapper mapper=sqlSession.getMapper(ConsultMapper.class);
            Consult consults=mapper.selectByPrimaryKey(consultid);
            view.addObject("consults",consults);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*园区客服 处理*/
    @RequestMapping(value = "/parkConsultancy/{consultid}",method = RequestMethod.GET)
    public ModelAndView parkConsultancy(@PathVariable Integer consultid)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("parkConsultancy");
            ConsultMapper mapper=sqlSession.getMapper(ConsultMapper.class);
            Consult consults=mapper.selectByPrimaryKey(consultid);
            view.addObject("consults",consults);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }


   /* 园区管理 结束*/

    /*企业服务 之订单管理*/
    @RequestMapping(value = "/companyOrder",method = RequestMethod.GET)
    public ModelAndView companyOrder ()
    {
        try
        {
            this.getSqlSession();
            ServiceOrderMapper mapper=sqlSession.getMapper(ServiceOrderMapper.class);
            List<Map<String,String>>  companyOrderDetailsOrdersList=mapper.selectCompanyOrderDetails();
            view.setViewName("companyOrder");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());

            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(companyOrderDetailsOrdersList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }

    }


    /*企业订单详情*/
    @RequestMapping(value = "/companyOrderDetails/{serviceorderid}/{category}",method = RequestMethod.GET)
    public ModelAndView companyOrderDetails(@PathVariable Integer serviceorderid,@PathVariable Integer category)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("companyOrderDetails");
            //  view.setViewName("test");
            ServiceOrderMapper mapper = sqlSession.getMapper(ServiceOrderMapper.class);
            List<ServiceOrder>  companyOrderlist=mapper.selectByPrimaryKey(serviceorderid);
            view.addObject("companyOrderlist",companyOrderlist);

            //查订单进度
            OrderStatusMapper mapper2 = sqlSession.getMapper(OrderStatusMapper.class);
            List<OrderStatus> orderStatusList=mapper2.selectOrderStatus(serviceorderid, category);
            view.addObject("orderStatusList",orderStatusList);

            //获得产品名称，产品类别
            List<Map<String,String>>  companyOrderOrdersList=mapper.selectCompanyOrderDetails();
            view.addObject("companyOrderOrdersList",companyOrderOrdersList);

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();
            String json = gson.toJson(orderStatusList);
            System.out.println(json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*企业订单编辑*/
    @RequestMapping(value = "/companyOrderManage/{serviceorderid}/{category}",method = RequestMethod.GET)
    public ModelAndView companyOrderManage(@PathVariable Integer serviceorderid,@PathVariable Integer category)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("companyOrderManage");
            //  view.setViewName("test");
            ServiceOrderMapper mapper = sqlSession.getMapper(ServiceOrderMapper.class);
            List<ServiceOrder>  companyOrderlist=mapper.selectByPrimaryKey(serviceorderid);
            view.addObject("companyOrderlist",companyOrderlist);

            //查订单进度
            OrderStatusMapper mapper2 = sqlSession.getMapper(OrderStatusMapper.class);
            List<OrderStatus> orderStatusList=mapper2.selectOrderStatus(serviceorderid, category);
            view.addObject("orderStatusList",orderStatusList);

            //获得产品名称，产品类别
            List<Map<String,String>>  companyOrderOrdersList=mapper.selectCompanyOrderDetails();
            view.addObject("companyOrderOrdersList",companyOrderOrdersList);

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();
            String json = gson.toJson(orderStatusList);
            System.out.println(json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }


    /*  APP 运营 下的 查询 开始*/

    @RequestMapping(value="/SliderImg", method = RequestMethod.GET)
    public ModelAndView SliderImg()
    {
        try
        {
            view.setViewName("slideringImg");

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
    }
    /*天使有约活动*/
    @RequestMapping(value="/appQueryActivity", method = RequestMethod.GET)
    public ModelAndView appQueryActivity ()
    {
        try
        {
            this.getSqlSession();
            ActivityMapper mapper=sqlSession.getMapper(ActivityMapper.class);
            List<Activity> activityList = mapper.selectAll(2);
            view.setViewName("appActivity");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(activityList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }

    }

    /*天使有约活动 详情*/
    @RequestMapping(value = "/appActivityDetails/{activityid}",method = RequestMethod.GET)
    public ModelAndView appActivityDetails(@PathVariable Integer activityid)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("appActivityDetails");
            ActivityMapper mapper=sqlSession.getMapper(ActivityMapper.class);
            Activity appactivities=mapper.selectByPrimaryKey(activityid);
            view.addObject("appactivities",appactivities);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*天使有约活动 编辑*/
    @RequestMapping(value = "/appAddActivity/{activityid}",method = RequestMethod.GET)
    public ModelAndView appAddActivity(@PathVariable Integer activityid)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("appAddActivity");
            ActivityMapper mapper=sqlSession.getMapper(ActivityMapper.class);
            Activity appactivities=mapper.selectByPrimaryKey(activityid);
            view.addObject("appactivities",appactivities);

            String titlename = "天使有约活动编辑";

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }


    /*天使有约活动申请  查询某一个活动的全部申请*/
    @RequestMapping(value = "/appActivityApply/{activityid}", method = RequestMethod.GET)
    public ModelAndView appActivityApply (@PathVariable Integer activityid)
    {
        try
        {
            this.getSqlSession();
            ActivityApplyMapper mapper=sqlSession.getMapper(ActivityApplyMapper.class);
            //List<ActivityApply> activityApplyList = mapper.selectAll(activityid);
            List<Map<String,String>> activityApplyList = mapper.activityApplyInfo(activityid);
            view.setViewName("appActivityApply");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(activityApplyList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }

    }

    /*天使有约活动申请 查询全部的活动申请*/
    @RequestMapping(value = "/appActivityApplyAll", method = RequestMethod.GET)
    public ModelAndView appActivityApplyAll ()
    {
        try
        {
            this.getSqlSession();
            ActivityApplyMapper mapper=sqlSession.getMapper(ActivityApplyMapper.class);
            //List<ActivityApply> activityApplyList = mapper.selectAll();
            List<Map<String,String>> activityApplyList = mapper.selectAllApply();
            view.setViewName("appActivityApply");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(activityApplyList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }

    }



    /*政策大厅*/
    @RequestMapping(value = "/appPolicy",method = RequestMethod.GET)
    public ModelAndView appPolicy ()
    {
        try
        {
            this.getSqlSession();
            AppPolicyMapper mapper=sqlSession.getMapper(AppPolicyMapper.class);
            List<AppPolicy> appPoliciesList = mapper.selectAll();
            view.setViewName("appConsulting");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(appPoliciesList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*政策大厅 资讯编辑*/
    @RequestMapping(value = "/appConsultingPolicyEdit/{apppolicyid}",method = RequestMethod.GET)
    public ModelAndView appConsultingPolicyEdit(@PathVariable Integer apppolicyid,ModelMap model)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appConsultingPolicyEdit");
            AppPolicyMapper mapper=sqlSession.getMapper(AppPolicyMapper.class);
            AppPolicy appPolicy=mapper.selectByPrimaryKey(apppolicyid);
            view.addObject("appPolicy",appPolicy);
            String titlename = "政策编辑";
            model.addAttribute("addOrUpadte","update");
            view.addObject("titlename",titlename);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*政策大厅 资讯详情*/
    @RequestMapping(value = "/appConsultingPolicyDetails/{apppolicyid}",method = RequestMethod.GET)
    public ModelAndView appConsultingPolicyDetails(@PathVariable Integer apppolicyid)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appConsultingPolicyDetails");
            AppPolicyMapper mapper=sqlSession.getMapper(AppPolicyMapper.class);
            AppPolicy appPolicy=mapper.selectByPrimaryKey(apppolicyid);
            view.addObject("appPolicy",appPolicy);
            String titlename = "APP资讯详情";
            view.addObject("titlename",titlename);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*园区管理*/
    @RequestMapping(value = "/appGarden",method = RequestMethod.GET)
    public ModelAndView appGarden ()
    {
        try
        {
            this.getSqlSession();
            ParkMapper mapper=sqlSession.getMapper(ParkMapper.class);
            List<Park> parksList = mapper.selectAll();
            view.setViewName("appGargen");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(parksList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*园区管理 编辑*/
    @RequestMapping(value = "/appAddPark/{parkid}",method = RequestMethod.GET)
    public ModelAndView appAddPark(@PathVariable Integer parkid,ModelMap model)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("appAddPark");
            ParkMapper mapper=sqlSession.getMapper(ParkMapper.class);
            Park parks=mapper.selectByPrimaryKey(parkid);
            String titlename = "园区编辑";
            model.addAttribute("addOrUpadte","update");
            view.addObject("titlename",titlename);
            view.addObject("parks",parks);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*园区管理 详情*/
    @RequestMapping(value = "/appGardenDetails/{parkid}",method = RequestMethod.GET)
    public ModelAndView appGardenDetails(@PathVariable Integer parkid)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("appGardenDetails");
            ParkMapper mapper=sqlSession.getMapper(ParkMapper.class);
            Park parks=mapper.selectByPrimaryKey(parkid);
            view.addObject("parks",parks);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*企业服务提供商*/
    @RequestMapping(value = "/appServer",method = RequestMethod.GET)
    public ModelAndView appServer ()
    {
        try
        {
            this.getSqlSession();
            ServiceProviderMapper mapper=sqlSession.getMapper(ServiceProviderMapper.class);
            //List<ServiceProvider> parksList = mapper.selectAll();
            List<Map<String,String>> producerList_gen = mapper.selectAllGeneralProducts();
            List<Map<String,String>> producerList_loan = mapper.selectAllLoanProducts();
            List<Map<String,String>> producerList_inv = mapper.selectAllInvestProducts();

            List<Map<String,String>> listAll = new ArrayList<Map<String,String>>();
            listAll.addAll(producerList_gen);
            listAll.addAll(producerList_inv);
            listAll.addAll(producerList_loan);


            //获得当前登陆的用户，即为“ 编辑”用户
/*            Map<String,String>  mapUser = new HashMap<String, String>();
            String name = getCurrentUser(session).getName();
            mapUser.put("userid",name);
            producerList.add(mapUser);*/


            view.setViewName("appServer");


            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();
           String json = gson.toJson(listAll);
           System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*企业服务提供商 详情*/
    @RequestMapping(value = "/appProducerDetails/{serviceproviderid}",method = RequestMethod.GET)
    public ModelAndView appProducerDetails(@PathVariable Integer serviceproviderid)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appProducerDetails");
            ServiceProviderMapper mapper=sqlSession.getMapper(ServiceProviderMapper.class);
            ServiceProvider serviceProviders=mapper.selectByPrimaryKey(serviceproviderid);
            view.addObject("serviceProviders",serviceProviders);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }
    /*企业服务提供商 编辑*/

    @RequestMapping(value = "/appProdcerEdit/{serviceproviderid}",method = RequestMethod.GET)
    public ModelAndView appProdcerEdit(@PathVariable Integer serviceproviderid)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appProdcerEdit");
            ServiceProviderMapper mapper=sqlSession.getMapper(ServiceProviderMapper.class);
            ServiceProvider serviceProvider=mapper.selectByPrimaryKey(serviceproviderid);
            view.addObject("serviceProvider",serviceProvider);

            String titlename = "企业服务提供商信息编辑";
            view.addObject("titlename",titlename);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*通用服务 批量查询  要的！！*/
    @RequestMapping(value = "/generalService",method = RequestMethod.GET)
    public ModelAndView generalService()
    {
        try
        {
            this.getSqlSession();
            GeneralServiceMapper mapper=sqlSession.getMapper(GeneralServiceMapper.class);
            // List<GeneralService> generalServicesList = mapper.selectAll();
            List<Map<String,String>> generalServicesList = mapper.selectGenralServiceInfo();
            view.setViewName("appProduct");


            //动态的将编辑页面的路径传递过去
            String pageUrl_edit = "appTongYongEdit";
            view.addObject("pageUrl_edit",pageUrl_edit);

//            传递详情页面的访问路径
            String pageUrl_detail = "productDetails";
            view.addObject("pageUrl_detail",pageUrl_detail);

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(generalServicesList);
            System.out.println(json);
            view.addObject("data", json);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*通用服务产品 详情*/
    @RequestMapping(value = "/productDetails/{generalServiceID}",method = RequestMethod.GET)
    public ModelAndView productDetails(@PathVariable Integer generalServiceID)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("productDetails");

            GeneralServiceMapper mapper = sqlSession.getMapper(GeneralServiceMapper.class);
            List<GeneralService>  generalServiceslist=mapper.selectByPrimaryKey(generalServiceID);
            view.addObject("generalServiceslist",generalServiceslist);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
    }

    /*通用服务产品 编辑*/
    @RequestMapping(value = "/appTongYongEdit/{generalServiceID}",method = RequestMethod.GET)
    public ModelAndView appTongYongEdit(@PathVariable Integer generalServiceID,ModelMap model)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appTongYongEdit");

            GeneralServiceMapper mapper = sqlSession.getMapper(GeneralServiceMapper.class);
            List<GeneralService>  generalServiceslist=mapper.selectByPrimaryKey(generalServiceID);
            view.addObject("generalServiceslist",generalServiceslist);

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();

            String json = gson.toJson(generalServiceslist);
            System.out.println(json);
            model.addAttribute("pageUrl","appTongYongEdit");
            view.addObject("data", json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*贷款服务产品管理 批量*/
    @RequestMapping(value = "/loanService",method = RequestMethod.GET)
    public ModelAndView loanService (ModelMap model)
    {
        try
        {
            this.getSqlSession();
            LoanServiceMapper mapper=sqlSession.getMapper(LoanServiceMapper.class);
            //List<LoanService> loanServicesList = mapper.selectAll();

            List<Map<String,String>> loanServicesList = mapper.selectLoanServiceInfo();
            view.setViewName("appProduct");

            //动态的将编辑页面的路径传递过去
            String pageUrl_edit = "appLoanEdit";
            view.addObject("pageUrl_edit",pageUrl_edit);

//            传递详情页面的访问路径
            String pageUrl_detail = "productLoanDetails";
            view.addObject("pageUrl_detail",pageUrl_detail);

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(loanServicesList);
            System.out.println(json);
            model.addAttribute("pageUrl","appLoanEdit");
            view.addObject("data", json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }

    }

    /*贷款服务产品管理 编辑*/
    @RequestMapping(value = "/appLoanEdit/{loanServiceID}",method = RequestMethod.GET)
    public ModelAndView appLoanEdit(@PathVariable Integer loanServiceID)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appLoanEdit");

            LoanServiceMapper mapper = sqlSession.getMapper(LoanServiceMapper.class);
            LoanService  loanServiceslist=mapper.selectByPrimaryKey(loanServiceID);
            view.addObject("loanServiceslist",loanServiceslist);

            String titlename = "贷款服务产品编辑";
            view.addObject("titlename",titlename);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*贷款服务产品管理 详情*/
    @RequestMapping(value = "/productLoanDetails/{loanServiceID}",method = RequestMethod.GET)
    public ModelAndView productLoanDetails(@PathVariable Integer loanServiceID)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("productLoanDetails");

            LoanServiceMapper mapper = sqlSession.getMapper(LoanServiceMapper.class);
            LoanService  loanServiceslist=mapper.selectByPrimaryKey(loanServiceID);
            view.addObject("loanServiceslist",loanServiceslist);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }


    /*投资服务产品管理 批量*/
    @RequestMapping(value = "/investService",method = RequestMethod.GET)
    public ModelAndView investService (ModelMap model)
    {
        try
        {
            this.getSqlSession();
            InvestmentServiceMapper mapper=sqlSession.getMapper(InvestmentServiceMapper.class);
            //List<InvestmentService> investmentServiceList = mapper.selectAll();
            List<Map<String,String>> investmentServiceList = mapper.selectInvsetServiceInfo();
            view.setViewName("appProduct");

            //动态的将编辑页面的路径传递过去
            String pageUrl_edit = "appInvestEdit";
            view.addObject("pageUrl_edit",pageUrl_edit);

//            传递详情页面的访问路径
            String pageUrl_detail = "productInvestDetails";
            view.addObject("pageUrl_detail",pageUrl_detail);
            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();

            String json = gson.toJson(investmentServiceList);
            System.out.println(json);

            //使产品页面的新建按钮跳转到相应产品的新建页面
            model.addAttribute("pageUrl","appInvestEdit");
            view.addObject("data", json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*投资服务产品管理 编辑*/
    @RequestMapping(value = "/appInvestEdit/{investserviceid}",method = RequestMethod.GET)
    public ModelAndView appInvestEdit(@PathVariable Integer investserviceid)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appInvestEdit");

            InvestmentServiceMapper mapper = sqlSession.getMapper(InvestmentServiceMapper.class);
            InvestmentService  inveswServiceslist=mapper.selectByPrimaryKey(investserviceid);
            view.addObject("inveswServiceslist",inveswServiceslist);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
        finally {
            this.closeSqlSession();
        }
    }

    /*投资服务产品管理 详情*/
    @RequestMapping(value = "/productInvestDetails/{investserviceid}",method = RequestMethod.GET)
    public ModelAndView productInvestDetails(@PathVariable Integer investserviceid)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("productInvestDetails");

            InvestmentServiceMapper mapper = sqlSession.getMapper(InvestmentServiceMapper.class);
            InvestmentService  inveswServiceslist=mapper.selectByPrimaryKey(investserviceid);
            view.addObject("inveswServiceslist",inveswServiceslist);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*APP客服*/
    @RequestMapping(value="/appConsultancy", method = RequestMethod.GET)
    public ModelAndView appConsultancy ()
    {
        try
        {
            this.getSqlSession();
            ConsultMapper mapper=sqlSession.getMapper(ConsultMapper.class);
            List<Consult> consultList = mapper.selectAll(2);
            view.setViewName("appconsultancy");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(consultList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }

    }

    /*APP客服 详情、查看页面（面前为一个页面）*/
    @RequestMapping(value = "/appreply/{consultid}",method = RequestMethod.GET)
    public ModelAndView appreply(@PathVariable Integer consultid)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appReply");
            ConsultMapper mapper=sqlSession.getMapper(ConsultMapper.class);
            Consult consults=mapper.selectByPrimaryKey(consultid);
            view.addObject("consults",consults);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
    }


    /*建议反馈*/
    @RequestMapping(value = "/appAdviceReback",method = RequestMethod.GET)
    public ModelAndView appAdviceReback ()
    {
        try
        {
            this.getSqlSession();
            SuggestionFeedbackMapper mapper=sqlSession.getMapper(SuggestionFeedbackMapper.class);
            List<SuggestionFeedback> suggestionFeedbackList = mapper.selectAll();
            view.setViewName("appAdviceReback");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(suggestionFeedbackList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
    }

    /*建议和反馈 详情页面*/
    @RequestMapping(value = "/appSuggestDetails/{suggestionfeedbackid}",method = RequestMethod.GET)
    public ModelAndView appSuggestDetails(@PathVariable Integer suggestionfeedbackid)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("appSuggestDetails");
            SuggestionFeedbackMapper mapper=sqlSession.getMapper(SuggestionFeedbackMapper.class);
            SuggestionFeedback suggestion=mapper.selectByPrimaryKey(suggestionfeedbackid);
            view.addObject("suggestion",suggestion);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*常见问题 */
    @RequestMapping(value = "/appProblem",method = RequestMethod.GET)
    public ModelAndView appProblem ()
    {
        try
        {
            this.getSqlSession();
            FaqMapper mapper=sqlSession.getMapper(FaqMapper.class);
            List<Faq> faqList = mapper.selectAll();
            view.setViewName("appProblem");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(faqList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*常见问题 详情*/
    @RequestMapping(value = "/appCommonProblem/{faqid}",method = RequestMethod.GET)
    public ModelAndView appCommonProblem(@PathVariable Integer faqid)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appCommonProblem");
            FaqMapper mapper=sqlSession.getMapper(FaqMapper.class);
            Faq questions=mapper.selectByPrimaryKey(faqid);
            view.addObject("questions",questions);

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
    }

    /*常见问题 编辑*/
    @RequestMapping(value = "/appCommonProblemEdit/{faqid}",method = RequestMethod.GET)
    public ModelAndView appCommonProblemEdit(@PathVariable Integer faqid,ModelMap model)
    {

        try
        {
            this.getSqlSession();
            view.setViewName("appCommonProblemEdit");
            FaqMapper mapper=sqlSession.getMapper(FaqMapper.class);
            Faq questions=mapper.selectByPrimaryKey(faqid);
            String titlename = "常见问题编辑";
            view.addObject("titlename",titlename);
            view.addObject("questions",questions);
            model.addAttribute("addOrUpdate","update");
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
    }

    /*用户设置*/
    @RequestMapping(value = "/appUserSetting",method = RequestMethod.GET)
    public ModelAndView appUserSetting ()
    {
        try
        {
            this.getSqlSession();
            UserMapper mapper=sqlSession.getMapper(UserMapper.class);
            List<User> userSettingList = mapper.selectAll();
            view.setViewName("appUserSetting");

            GsonBuilder gb = new GsonBuilder();
            gb.registerTypeAdapter(String.class, new GenericAdapter());
            //Gson gson = gb.create();

            //Gson gson=GsonBuilder().registerTypeAdapterFactory(newNullStringToEmptyAdapterFactory()).create();
            Gson gson = new GsonBuilder().registerTypeAdapter(News.class, new GenericAdapter()).create();


            String json = gson.toJson(userSettingList);
            System.out.println(json);
            view.addObject("data",json);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }
    }

    /*用户设置 编辑页面*/
    @RequestMapping(value = "/appUserEdit/{userid}",method = RequestMethod.GET)
    public ModelAndView appUserEdit(@PathVariable Integer userid,ModelMap model)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appUserEdit");
            UserMapper mapper = sqlSession.getMapper(UserMapper.class);
            User users= mapper.selectByPrimaryKey(userid);

            String titlename = "编辑";
            view.addObject("titlename",titlename);
            view.addObject("users", users);
            model.addAttribute("addOrUpdate","update");
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();

            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    /*数据字典  不知道对应的表示哪一张，所以未完成 暂时不做了*/

    //查询天使有约活动简介
    @RequestMapping("/appAngleIns")
    public ModelAndView queryAppAngleIns(ModelMap model)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appAngleIns");
            SimpleTableMapper simpleTableMapper = sqlSession.getMapper(SimpleTableMapper.class);
            SimpleTable simpleTable=simpleTableMapper.selectByCategory(1);

            if(simpleTable!=null){
                view.addObject("simpleTable1",simpleTable);
                model.addAttribute("addOrUpdate","update");
            }else{
                model.addAttribute("addOrUpdate","add");
            }
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    //查询关于页面
    @RequestMapping("/appAbout")
    public ModelAndView queryAppAbout(ModelMap model)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appAbout");
            SimpleTableMapper simpleTableMapper = sqlSession.getMapper(SimpleTableMapper.class);
            SimpleTable simpleTable=simpleTableMapper.selectByCategory(2);
     /*//       System.out.print(simpleTable.getContent());*/
            if(simpleTable!=null){
                view.addObject("simpleTable2",simpleTable);
                model.addAttribute("addOrUpdate","update");
            }else{
                model.addAttribute("addOrUpdate","add");
            }

            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }

    //查询接入平台
    @RequestMapping("/appPlatform")
    public ModelAndView queryAppPlatform(ModelMap model)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appPlatform");
            SimpleTableMapper simpleTableMapper = sqlSession.getMapper(SimpleTableMapper.class);
            SimpleTable simpleTable=simpleTableMapper.selectByCategory(3);
            //      System.out.print(simpleTable.getContent());
            if(simpleTable!=null){
                view.addObject("simpleTable3",simpleTable);
                model.addAttribute("addOrUpdate","update");
            }else{
                model.addAttribute("addOrUpdate","add");
            }
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }



    //查询用户协议
    @RequestMapping("/appUserProtocol")
    public ModelAndView queryAppUserProtocol(ModelMap model)
    {
        try
        {
            this.getSqlSession();
            view.setViewName("appUserProtocol");
            SimpleTableMapper simpleTableMapper = sqlSession.getMapper(SimpleTableMapper.class);
            SimpleTable simpleTable=simpleTableMapper.selectByCategory(4);
            //         System.out.print(simpleTable.getContent());
            if(simpleTable!=null){
                view.addObject("simpleTable4",simpleTable);
                model.addAttribute("addOrUpdate","update");
            }else{
                model.addAttribute("addOrUpdate","add");
            }
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            view.setViewName(getErrorPage());
            return view;
        }finally {
            this.closeSqlSession();
        }
    }


        /*APP 运营 下的 查询 结束*/


    //================日志查询开始  by Ken Chen================
    //------------日志选择模块------------
    @RequestMapping(value ="/log/{logname}")
    public ModelAndView queryLog(@PathVariable String logname)
    {
        System.out.print("*******************"+logname+"*********************");
        Map<String,String> tableWithName=new HashMap<String,String>();
        tableWithName.put("news","园区资讯");
        tableWithName.put("activityT1","园区活动");
        tableWithName.put("appPolicy","政策大厅");
        tableWithName.put("activityT2","天使有约活动"); //天使有约活动
        tableWithName.put("serviceProvider","企业服务提供商管理"); //
        tableWithName.put("generalService","通用服务产品管理");
        tableWithName.put("loanService","贷款服务产品管理");
        tableWithName.put("investmentService","投资服务产品管理");
        tableWithName.put("Faq","常见问题");

        if(tableWithName.get(logname)!=null)
        {

            if(logname.equals("activityT1")) //园区活动 type1
            {
                return queryActivities(1,tableWithName.get(logname));
            }
            if(logname.equals("systemSetting"))
            {
                //系统设置
                return queryCommonLogs("resource",tableWithName.get(logname));
            }
            if(logname.equals("activityT2")) //天使有约活动
            {
                return queryActivities(2,tableWithName.get(logname));
            }
            return queryCommonLogs(logname,tableWithName.get(logname));
        }
        else
        {
            view.setViewName(getErrorPage());
            return view;
        }
    }



    //-----------------日志查询功能模块-------------------------
    //通用日志查询  --用于查询简单日志，即不需联合多表的日志
    private ModelAndView queryCommonLogs(String table,String tableTitle)
    {
        try
        {
            this.getSqlSession();
            LogMapper mapper=sqlSession.getMapper(LogMapper.class);
            List<Log> newsLogList = mapper.queryCommonLogs(table);
            view.setViewName("history");

            GsonBuilder gb = new GsonBuilder();
            Gson gson = gb.create();
            String json = gson.toJson(newsLogList);

            System.out.println(json);
            view.addObject("data",json);
            view.addObject("tableTitle",tableTitle);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            view.setViewName(getErrorPage());
            return view;
        }
    }

    //园区活动查询 type1:园区活动  type2:天使活动
    private ModelAndView queryActivities(int type,String tableTitle)
    {
        try
        {
            this.getSqlSession();
            LogMapper mapper=sqlSession.getMapper(LogMapper.class);
            List<Log> newsLogList = mapper.queryActivity(type);
            view.setViewName("history");

            GsonBuilder gb = new GsonBuilder();
            Gson gson = gb.create();
            String json = gson.toJson(newsLogList);

            System.out.println(json);
            view.addObject("data",json);
            view.addObject("tableTitle",tableTitle);
            return view;
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            view.setViewName(getErrorPage());
            return view;
        }
    }


    //系统设置
//================日志查询结束================
}

